package net.maku.wx.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import net.maku.framework.common.utils.Result;
import net.maku.system.service.SysAuthService;
import net.maku.wx.service.WxAuthService;
import net.maku.wx.vo.WxLoginVO;
import net.maku.system.vo.SysTokenVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 认证管理
 *
 * @author 阿沐 babamu@126.com
 */
@RestController
@RequestMapping("sys/auth")
@Tag(name = "小程序认证管理")
@AllArgsConstructor
public class WxAuthController {
    private final WxAuthService wxAuthService;

    @PostMapping("openid")
    @Operation(summary = "登录")
    public Result<SysTokenVO> openid(@RequestBody WxLoginVO login) {
        // TODO 获取用户openid
        String openid = "";
        SysTokenVO token = wxAuthService.loginByOpenid(openid);
        return Result.ok(token);
    }
}
